
import 'package:flutter/material.dart';
import 'package:xsdk_flutter/xsdk/xsdk_flutter_package.dart';


/*
测试serverSocket
 */
class TestClientSocketStatePage extends XPageState{

  TestClientSocketStatePage();

  String clientItemMsg='';

  final TextEditingController _textFieldController = TextEditingController();

  @override
  Widget getBodyWidget(BuildContext context) {
    return XWidgetUtils.getLayoutColumn(children: [
      XWidgetUtils.getWidgetText('socket socket'),
      XWidgetUtils.getWidgetText(clientItemMsg),
      XWidgetUtils.getWidgetTextField(helperText: '输入服务端地址',controller: _textFieldController),
      XWidgetUtils.getWidgetButtonOutlined(
          child: XWidgetUtils.getWidgetText('开启Client'),
          onPressed: (){
            XBaseDevice baseDevice=XBaseDevice();
            baseDevice.ip='192.168.8.71';
            baseDevice.port=2221;
            XSocketUtils.addDevice(baseDevice);
          }
      ),
      XWidgetUtils.getWidgetButtonOutlined(
          child: XWidgetUtils.getWidgetText('发送消息'),
          onPressed: (){
            Map testMsg={
              'msgType':'baiduTTS',
              'speakMsg':'A123',
            };
            XBaseQueueMessage msg=XBaseQueueMessage(msgId: '111111',message: testMsg);
            //XSocketUtils.sendMsgToDevice_test(isServerSendToClientMessage: false, ip: '192.168.8.71',port:2221, msg:msg );
            XTTSUtils.speak('A123');
          }
      ),
    ]);
  }


  @override
  void onStart() {

  }

  @override
  Future<void> updateData({int pageIndex=1}) async {
  }





}